package cn.itcast.dagger_demo;

import java.util.concurrent.TimeUnit;

import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Administrator on 2016/8/3.
 */

@Module
public class AppModule {

    @Provides
    public OkHttpClient provideOkHttpClient() {

        return new OkHttpClient.Builder()
                .readTimeout(30 * 1000, TimeUnit.MICROSECONDS)
                .connectTimeout(30 * 1000, TimeUnit.MICROSECONDS)
                .build();
    }

    @Provides
    public Retrofit provideRetrofit(OkHttpClient okHttpClient) {

        return new Retrofit.Builder().client(okHttpClient)
                .baseUrl("http://192.168.209.1:8080/")
                .addConverterFactory(GsonConverterFactory.create()).build();
    }

}
